package net.chathu.airgw.model 
{
	import flash.utils.Dictionary;
	import net.chathu.airgw.Debug;
	/**
	 * Olyan szobarol tarol infot, ahova beleptunk:
	 * _roomId: a szoba idje
	 * _userlist: a szobaban levo felhasznalok idje + parba allitva a jogosultsagokkal
	 * @author ze
	 */
	public class JoinedRoomInfo 
	{
		//private static const ROOM_RIGHTS_OWNER:int = 2;
		private static const ROOM_RIGHTS_USER:int = 1;
		private static const ROOM_RIGHTS_MODERATOR:int = 2;
		private var _roomId:int;
		private var _userlist:Dictionary;
		public function JoinedRoomInfo(roomId:int) {
			_roomId = roomId
			_userlist = new Dictionary();
		}
		
		public function get roomId():int {
			return _roomId;
		}
		
		public function addUser(userId:int, rights:int):void {
			_userlist[userId] = rights;
		}
		
		public function removeUser(userId:int):void {
			delete _userlist[userId];
		}
		
		public function get usernum():int
		{
			var cntr:int = 0;
			for (var x:* in _userlist)
			{
				cntr++;
			}
			return cntr;
		}
	
		public function checkUserById(userId:int):Boolean {
			//TODO: ellenorizni!
			return (_userlist[userId] != null);
		}
		
		public function get userlistWithRights():Dictionary {
			return _userlist;
		}
		
		public function getUserRights(user:User):int {
			return _userlist[user.id];
		}
		
		public function hasUserOwerRights(user:User):Boolean {
			//return _userlist[user.id] == ROOM_RIGHTS_OWNER;
			return false; //eleg a kiemelt jog kezeles?
		}
		
		public function hasUserModeratorRights(user:User):Boolean {
			return _userlist[user.id]==ROOM_RIGHTS_MODERATOR;
		}
	}

}